<template>
  <div class="goods-hot" ref="target">
    <h3 v-if="type === 1">24小时热销榜</h3>
    <h3 v-else-if="type === 2">热销周榜</h3>
    <h3 v-else-if="type === 3">热销总榜</h3>
    <GoodsItem :goods="item" v-for="item in list" :key="item.id"></GoodsItem>
  </div>
</template>

<script>
import GoodsItem from '@/views/category/components/goods-item.vue'
import { findHotGoods } from '@/api/goods'
import { useLazyData } from '@/hooks'
export default {
  components: { GoodsItem },
  name: 'GoodsHot',
  props: {
    type: {
      type: Number,
      default: 1
    },
    goodsId: {
      type: String,
      default: ''
    }
  },
  setup (props) {
    // findGoodsHot({ id: props.goodsId, type: props.type }).then(({ result }) => {
    //   list.value = result
    // })
    const { list, target } = useLazyData(() => findHotGoods({ id: props.goodsId, type: props.type }))
    console.log(list)
    return { list, target }
  }
}
</script>
